/**
 * 
 */
package com.metagurukul.metaspace.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * @author bhagyesh
 * 
 */
public class WorkDetailsForm extends ActionForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int departmentId;
	private int projectId;
	private int roleId;

	/**
	 * 
	 */
	public WorkDetailsForm() {
	}

	/**
	 * @return the department
	 */
	public int getDepartment() {
		return departmentId;
	}

	/**
	 * @param department
	 *            the department to set
	 */
	public void setDepartment(int departmentId) {
		this.departmentId = departmentId;
	}

	/**
	 * @return the project
	 */
	public int getProject() {
		return projectId;
	}

	/**
	 * @param project
	 *            the project to set
	 */
	public void setProject(int project) {
		this.projectId = project;
	}

	/**
	 * @return the role
	 */
	public int getRole() {
		return roleId;
	}

	/**
	 * @param role
	 *            the role to set
	 */
	public void setRole(int role) {
		this.roleId = role;
	}
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		// TODO Auto-generated method stub
		ActionErrors errors = new ActionErrors();
		if (departmentId == -1 ) {
			errors.add("department", new ActionMessage("error.department.required"));
		}
		if (roleId == -1 ) {
			errors.add("role", new ActionMessage("error.role.required"));
		}
		if (projectId == -1 ) {
			errors.add("project", new ActionMessage("error.project.required"));
		}
		return errors;
	}
}
